Micron Document
🎖️GitЯра🎖️

Node / meshtastic / Meshtastic-Android / files / core / ui / src / commonTest / kotlin / org / meshtastic / core / ui / component / StatusSurfaceTest.kt

Displaying Raw • Download

core/ui/src/commonTest/kotlin/org/meshtastic/core/ui/component/StatusSurfaceTest.kt c2a8e67aee4db8f77b7dc6924dcebfbdfba1bf5e (c2a8e67a) Text, 2.72 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.ui.component

Tff7b72import T7ee787androidx.compose.ui.graphics.Color
Tff7b72import T7ee787androidx.compose.ui.graphics.compositeOver
Tff7b72import T7ee787androidx.compose.ui.graphics.lerp
Tff7b72import T7ee787org.meshtastic.core.ui.theme.MIN_GRAPHICAL_CONTRAST
Tff7b72import T7ee787org.meshtastic.core.ui.theme.MIN_TEXT_CONTRAST
Tff7b72import T7ee787org.meshtastic.core.ui.theme.contrastRatio
Tff7b72import T7ee787org.meshtastic.core.ui.theme.surfaceContainerHighestLight
Tff7b72import T7ee787kotlin.test.Test
Tff7b72import T7ee787kotlin.test.assertTrue

Tff7b72class T56d364StatusSurfaceTest Tb4b4b4{

T8b949e// The actual StatusColors token values (kept in sync with CustomColors.StatusColors).
Tff7b72private Tff7b72val Te6edf3green Tff7b72= Te6edf3ColorTb4b4b4(T79c0ff0Te6edf3xFF3FB86DTb4b4b4)
Tff7b72private Tff7b72val Te6edf3statusColors Tff7b72=
Te6edf3mapOfTb4b4b4(
Ta5d6ff"Ta5d6ffgreenTa5d6ff" Te6edf3to Te6edf3greenTb4b4b4,
Ta5d6ff"Ta5d6ffyellowTa5d6ff" Te6edf3to Te6edf3ColorTb4b4b4(T79c0ff0Te6edf3xFFE8A33ETb4b4b4)Tb4b4b4,
Ta5d6ff"Ta5d6fforangeTa5d6ff" Te6edf3to Te6edf3ColorTb4b4b4(T79c0ff0Te6edf3xFFFF8800Tb4b4b4)Tb4b4b4,
Ta5d6ff"Ta5d6ffredTa5d6ff" Te6edf3to Te6edf3ColorTb4b4b4(T79c0ff0Te6edf3xFFE05252Tb4b4b4)Tb4b4b4,
Tb4b4b4)

T8b949e// StatusScrim is translucent, so test the effective color over the lightest surface it can REALISTICALLY sit on:
T8b949e// the light card surface (chip base) tinted toward the lightest possible node color (white) at max emphasis.
Tff7b72private Tff7b72val Te6edf3lightestBackdrop Tff7b72= Te6edf3lerpTb4b4b4(Te6edf3surfaceContainerHighestLightTb4b4b4, Te6edf3ColorTb4b4b4.Te6edf3WhiteTb4b4b4, Te6edf3NODE_TINT_EMPHASIZEDTb4b4b4)
Tff7b72private Tff7b72val Te6edf3effectiveScrim Tff7b72= Te6edf3StatusScrimTb4b4b4.Te6edf3compositeOverTb4b4b4(Te6edf3lightestBackdropTb4b4b4)

Tf0883e@Test
Tff7b72fun Td2a8ffgoodGreenMeetsTextContrastTb4b4b4(Tb4b4b4) Tb4b4b4{
T8b949e// Green carries the common cases (signed shield, good signal) and must clear AA text contrast.
Te6edf3assertTrueTb4b4b4(
Te6edf3contrastRatioTb4b4b4(Te6edf3greenTb4b4b4, Te6edf3effectiveScrimTb4b4b4) Tff7b72>Tff7b72= Te6edf3MIN_TEXT_CONTRASTTb4b4b4,
Ta5d6ff"Ta5d6ffgreen must meet AA text on the scrim (got Tffd700${Te6edf3contrastRatioTb4b4b4(Te6edf3greenTb4b4b4, Te6edf3effectiveScrimTb4b4b4)Tffd700}Ta5d6ff)Ta5d6ff"Tb4b4b4,
Tb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ffeveryStatusColorClearsGraphicalContrastTb4b4b4(Tb4b4b4) Tb4b4b4{
T8b949e// Translucency trades some headroom: the darkest token (red) holds the 3:1 graphical floor, not full text AA.
Tff7b72for Tb4b4b4(Tb4b4b4(Te6edf3nameTb4b4b4, Te6edf3colorTb4b4b4) Tff7b72in Te6edf3statusColorsTb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3ratio Tff7b72= Te6edf3contrastRatioTb4b4b4(Te6edf3colorTb4b4b4, Te6edf3effectiveScrimTb4b4b4)
Te6edf3assertTrueTb4b4b4(Te6edf3ratio Tff7b72>Tff7b72= Te6edf3MIN_GRAPHICAL_CONTRASTTb4b4b4, Ta5d6ff"Ta5d6ffstatus 'Tffd700$Te6edf3nameTa5d6ff' must clear 3:1 on the scrim (got Tffd700$Te6edf3ratioTa5d6ff)Ta5d6ff"Tb4b4b4)
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.05s